<template>
    <div name='pager_add'>
          <link rel="stylesheet" href="/static/css/b.css">
          <link rel="stylesheet" href="/static/css/f.css">
          <link rel="stylesheet" href="/static/css/base.css">
          <link rel="stylesheet" href="/static/css/form.css">
        <body>
            <Header></Header>
            <section>
                <div class="mainwrapper">

                    <!-- 侧边栏 -->
                    <Sidebar></Sidebar>
                    <!-- /侧边栏 -->

                    <div class="mainpanel">
                        <div class="contentpanel">
                            <div class="row row-stat">

             


<div id="content" class="colM">
        
        <h1>增加 考题内容</h1>
        <div id="content-main">




    <input type="hidden" name="csrfmiddlewaretoken">
<div>







  <fieldset class="module aligned ">
    
    
    
        <div class="form-row field-examination_name">
            
            
                <div>
                    
                    
                        <label class="required" >考题名:</label>
                        
                            <input type="text" class="vTextField" maxlength="100" required=""   v-model="examination_name">
                        
                    
                    
                </div>
            
        </div>
    
        <div class="form-row field-examination_text">
                <div>
                        <label class="required" >考题内容和答案:</label>
                            <textarea name="examination_text" cols="40" rows="10" class="vLargeTextField" required="" id="id_examination_text" v-model="examination_text"></textarea>
                </div>
        </div>
        <div class="form-row field-examination_answer">
                <div>
                        <label class="required" for="id_examination_answer">考题答案:</label>
                            <input type="text" name="examination_answer" class="vTextField" maxlength="100" required="" id="id_examination_answer" v-model="examination_answer">
                </div>      
        </div>
    
        <div class="form-row field-examination_type">
                <div>
                        <label class="required" for="id_examination_type">题型分类:</label>
                        
                            <div class="related-widget-wrapper">
    <select name="examination_type" required="" id="id_examination_type" v-model="examination_type">
  <option value="" selected="">---------</option>
  <option v-for="i in question_types" :key="i.id" :value="i.id">{{i.type_name}}</option>

</select>
    
        <a class="related-widget-wrapper-link change-related" id="change_id_examination_type" data-href-template="/admin/app/question_types/__fk__/change/?_to_field=id&amp;_popup=1" title="更改选中的题型分类"><img src="/static/images/修改.svg" alt="修改"></a><a class="related-widget-wrapper-link add-related" id="add_id_examination_type" href="/admin/app/question_types/add/?_to_field=id&amp;_popup=1" title="增加另一个 题型分类"><img src="/static/images/添加.svg" alt="增加"></a>
    
</div>
                        
                    
                    
                </div>
            
        </div>
    
        <div class="form-row field-examination_a">
            
            
                <div>
                    
                    
                        <label class="required" for="id_examination_a">A:</label>
                        
                            <input type="text" name="examination_a" class="vTextField" maxlength="100" required="" id="id_examination_a" v-model="examination_a">
                        
                    
                    
                </div>
            
        </div>
    
        <div class="form-row field-examination_b">
            
            
                <div>
                    
                    
                        <label class="required" for="id_examination_b">B:</label>
                        
                            <input type="text" name="examination_b" class="vTextField" maxlength="100" required="" id="id_examination_b" v-model="examination_b">
                        
                    
                    
                </div>
            
        </div>
    
        <div class="form-row field-examination_c">
            
            
                <div>
                    
                    
                        <label class="required" for="id_examination_c">C:</label>
                        
                            <input type="text" name="examination_c" class="vTextField" maxlength="100" required="" id="id_examination_c" v-model="examination_c">
                        
                    
                    
                </div>
            
        </div>
    
        <div class="form-row field-examination_d">
            
            
                <div>
                    
                    
                        <label class="required" for="id_examination_d">D:</label>
                        
                            <input type="text" name="examination_d" class="vTextField" maxlength="100" required="" id="id_examination_d" v-model="examination_d">
                        
                    
                    
                </div>
            
        </div>
    
 
    
</fieldset>













<div class="submit-row">


<input type="submit" value="保存" @click="_save" class="default" name="_save">
<input type="submit" value="保存并增加另一个" @click="_addanother" name="_addanother">
</div>





</div>
</div>

        
        <br class="clear">
    </div>






















                            </div><!-- row -->
                        </div>
                        <!-- contentpanel -->
                    </div>
                    <!-- mainpanel -->
                </div>
                <!-- mainwrapper -->
            </section>
 
        </body>
    </div>
    
    
    
   
</template>

<script>
import axios from 'axios'
export default {
    name:'Paper_add_new',
    data() {
        return {
            question_types:[],
            examination_name:'',
            examination_text:'',
            examination_answer:'',
            examination_type:'',
            examination_a:'',
            examination_b:'',
            examination_c:'',
            examination_d:'',
        }
    },  
    mounted () {
       axios({
                url:this.$api+'/user/all_Question_types/',
                method:'get',
            }).then(res=>{
                if(res.data.code==200){
                    this.question_types=res.data.question_types
                }
            })
    },
    methods: {
        _save(){
             axios({
                url:this.$api+'/user/Examination_questions/',
                method:'post',
                data:{
                    'examination_name':this.examination_name,
                    'examination_text':this.examination_text,
                    'examination_answer':this.examination_answer,
                    'examination_type_id':this.examination_type,
                    'examination_a':this.examination_a,
                    'examination_b':this.examination_b,
                    'examination_c':this.examination_c,
                    'examination_d':this.examination_d,
                    'final_exam_id':window.localStorage.getItem('exam_id')
                }
            }).then(res=>{
                if(res.data.code==200){
                    alert('成功')
                    this.$router.push({path: '/paper_add'})
                }else{
                    alert('请填写空字段')
                }
            })
        },
        _addanother(){
            axios({
                url:this.$api+'/user/Examination_questions/',
                method:'post',
                data:{
                    'examination_name':this.examination_name,
                    'examination_text':this.examination_text,
                    'examination_answer':this.examination_answer,
                    'examination_type_id':this.examination_type,
                    'examination_a':this.examination_a,
                    'examination_b':this.examination_b,
                    'examination_c':this.examination_c,
                    'examination_d':this.examination_d,
                    'final_exam_id':window.localStorage.getItem('exam_id')
                }
            }).then(res=>{
                if(res.data.code==200){
                      alert(成功)
                      window.location.reload()  
                }else{
                    alert('请填写空字段')
                }
            })
        },

  
    }
 
 


}





</script>
